/*
 * @Autor: Ruohong Yu
 * @Date: 2022-08-31 22:22:04
 * @Description: file content
 * @FilePath: \ebook\vue.config.js
 */
const { defineConfig } = require('@vue/cli-service')

// function mock (devServer, url, data) {
//   devServer.app.get(url, (request, response) => {
//     response.json(data)
//   })
// }
// const homeData = require('./src/mock/bookHome')
// const shelfData = require('./src/mock/bookShelf')
// const listData = require('./src/mock/bookList')
// const flatListData = require('./src/mock/bookFlatList')

module.exports = defineConfig({
  transpileDependencies: true,
  parallel: false,

  // 打包加上，平时本地运行时注释
  // publicPath: './',
  publicPath: process.env.NODE_FNV === 'production' ? './' : '/',

  devServer: {
    // onBeforeSetupMiddleware (devServer) {
    //   mock(devServer, '/book/home', homeData)
    //   mock(devServer, '/book/shelf', shelfData)
    //   mock(devServer, '/book/list', listData)
    //   mock(devServer, '/book/flat-list', flatListData)
    // }
  },
  css: {
    loaderOptions: {
      sass: {
        // 全局引入变量和 mixin
        additionalData: `
          @import "./src/assets/styles/global.scss";
        `
      }
    }
  },
  configureWebpack: {
    performance: {
      hints: 'warning',
      maxAssetSize: 524288,
      maxEntrypointSize: 524288
    }
  }
})
